<div class="layuimini-container">
    <form id="app-form" class="layui-form layuimini-form">

        <div class="layui-form-item">
            <label class="layui-form-label required">用户uid</label>
            <div class="layui-input-block">
                <input type="text" name="uid" class="layui-input" lay-verify="required" lay-reqtext="请输入用户uid" placeholder="请输入用户uid" value="{$row.uid|default=''}">
                <tip>填写用户uid。</tip>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label required">签到时间</label>
            <div class="layui-input-block">
                <input type="text" name="sign_date" data-date="" data-date-type="datetime" class="layui-input"  placeholder="请选择签到时间" value="{$row.sign_date|default=''}">
                <tip>请输入签到时间。</tip>
            </div>
        </div>>
        <div class="layui-form-item">
            <label class="layui-form-label required">所属社区</label>
            <div class="layui-input-inline">
                <select name="district" lay-filter="district">
                    {foreach $district as $vo}
                    <option value="{$vo.name}" {if $row.district==$vo.name}selected=""{/if}>{$vo.name|default=''}</option>
                    {/foreach}
                </select>
            </div>
            <label class="layui-form-label required">乡镇</label>
            <div class="layui-input-inline">
                <select name="town" lay-filter="town">
                    {foreach $town as $vo}
                    <option value="{$vo.name}" {if $row.town==$vo.name}selected=""{/if}>{$row.town|default=''}</option>
                    {/foreach}
                </select>
            </div>
            <label class="layui-form-label required">社区</label>
            <div class="layui-input-inline">
                <select name="community" lay-filter="community">
                    {foreach $community as $vo}
                    <option value="{$vo.name}" {if $row.community==$vo.name}selected=""{/if}>{$row.community|default=''}</option>
                    {/foreach}
                </select>
            </div>
            <label class="layui-form-label required">社区党支部</label>
            <div class="layui-input-inline">
                <input type="text" name="party" class="layui-input" lay-verify="required" lay-reqtext="请输入党支部" placeholder="请输入党支部  " value="{$row.party|default=''}">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label disabled">签到类型</label>
            <div class="layui-input-block">
                {foreach ['签到','签退'] as $key=>$vo}
                <input type="radio" name="type" value="{$vo}" title="{$vo}" {if $row.type==$vo}checked=""{/if}>
                {/foreach}
                <tip>请选择签到类型。</tip>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label required">工作内容</label>
            <div class="layui-input-block">
                <input type="text" name="content" class="layui-input" lay-verify="required" lay-reqtext="请输入工作内容" placeholder="请输入工作内容" value="{$row.content|default=''}">
                <tip>请输入工作内容。</tip>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label required">工作图片</label>
            <div class="layui-input-block layuimini-upload">
                <input name="image" class="layui-input layui-col-xs6" lay-verify="required" lay-reqtext="请上传工作图片" placeholder="请上传工作图片" value="{$row.image|default=''}">
                <div class="layuimini-upload-btn">
                    <span><a class="layui-btn" data-upload="image" data-upload-number="one" data-upload-exts="png|jpg|ico|jpeg" data-upload-icon="image"><i class="fa fa-upload"></i> 上传</a></span>
                </div>
            </div>
        </div>
        <div class="hr-line"></div>
        <div class="layui-form-item text-center">
            <button type="submit" class="layui-btn layui-btn-normal layui-btn-sm" lay-submit>确认</button>
            <button type="reset" class="layui-btn layui-btn-primary layui-btn-sm">重置</button>
        </div>

    </form>
    <script>
        layui.use(['form'])
        {
            var form = layui.form
            form.on('select(district)', function (data) {
                var name = data.value
                $("select[name = 'community']").html('')
                $.post("getOptions", {name: name}, function (res) {
                    if(res.code==0) {
                        var towns= res.data;
                        var options="";
                        for (var i = 0; i < towns.length; i++) {
                            var town = towns[i];
                            options+=' <option value="'+town.name+'">'+town.name+'</option>';
                        }
                        $("select[name='town']").html(options)
                        form.render('select');
                    }
                    var town = $("select[name='town']").val()
                    $.post("getOptions", {name: town}, function (res) {
                        if(res.code==0) {
                            var communitys= res.data;
                            var options="";
                            for (var i = 0; i < communitys.length; i++) {
                                var community = communitys[i];
                                options+=' <option value="'+community.name+'">'+community.name+'</option>';
                            }
                            $("select[name='community']").html(options)
                            form.render('select');
                        }
                    })
                })
            });
            form.on('select(town)', function (data) {
                var name = data.value
                $.post("getOptions", {name: name}, function (res) {
                    if(res.code==0) {
                        var communitys= res.data;
                        var options="";
                        for (var i = 0; i < communitys.length; i++) {
                            var community = communitys[i];
                            options+=' <option value="'+community.name+'">'+community.name+'</option>';
                        }
                        $("select[name='community']").html(options)
                        form.render('select');
                    }
                })
            });
        }
    </script>
</div>